﻿using System.Linq;
using AprenderComendo.Models;
using NHibernate;
using NHibernate.Linq;

namespace AprenderComendo.Infrastructure.Persistence
{
    public class ThoughtWorkerRepository: AbstractRepository, IPersonRepository
    {
        public ThoughtWorkerRepository(ISession session): base(session)
        {
        }

        public void Save(Person person)
        {
            Session.Save(person);
        }

        public Person FindByName(string name)
        {
            return (from person in Session.Linq<ThoughtWorker>() 
                   where person.Name == name 
                   select person).First();

        }
    }
}